#include <iostream>
#include <pthread.h>
#include <cstdio>
#include <unistd.h>

int* p = nullptr;

void* routine(void* args)
{
    int a = 123;

    p = &a;

    while(true) {sleep(1);}
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, routine, nullptr);
    sleep(3);
    std::cout << *p << std::endl;

    pthread_join(tid, nullptr);

    return 0;
}